package org.qiuer.ast.assign;

import org.qiuer.ast.expression.function.Function;
import org.qiuer.run.Context;
import org.qiuer.func.function.UserDefineFunction;
import org.qiuer.exception.IException;

// 例如： function name(){} 声明的函数。
public class FunctionDeclaration extends Function implements IDeclaration {
  public String type = "FunctionDeclaration";

  @Override
  public void compile() throws IException {

  }

  public Object run(Context context) throws IException {
    context.println("[FunctionDeclaration] name=" + this.id.name);
    Function function = new UserDefineFunction(this.id.name, this.body, this.params);
    function.compile();
    context.declareVariable(id.name, function, AssignKind.CONST);
    return null;
  }
}